package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.NewQueryObject;
import cn.wolfcode.trip.base.service.INewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


//日报资源的控制器
@RestController
@RequestMapping("/militaries")
public class MilitaryController {
    @Autowired
    private INewService newService;

    /*
    根据日报的id查询日报信息
    资源:/news/{id}
    动作:GET
    参数:
     */
    @GetMapping("/{id}")
    public Object getNewById(@PathVariable Long id) {
        return newService.get(id);
    }

    /**
     * 查询今天头条信息
     * @param qo
     * @return
     */
    @GetMapping
    public Object getCommend(NewQueryObject qo ) {
        qo.setOrderBy("releaseTime desc");
        qo.setOrderBy("type");
        return newService.query(qo);
    }
}
